<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>筛选数组元素</title>
</head>

<body>
    <script>
        // 1.声明一个新的数组用于存放新数据newArr
        // 2.遍历原来的旧数组，找出大于等于10的元素
        // 3.依次追加到新数组newArr


        /* var newArr = [];
        var arr = [1, 2, 3, 4, 5, 67, 56, 7, 23, 45, 87, 6, 34];
        var j = 0;
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
            
                newArr[j] = arr[i];
                j++
            }
        }
        console.log(newArr); */



        var newArr = [];
        var arr = [1, 2, 3, 4, 5, 67, 56, 7, 23, 45, 87, 6, 34];

        for (var i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {

                newArr[newArr.length] = arr[i]; //通过检测长度进行存储

            }
        }
        console.log(newArr);
    </script>
</body>

</html>